
import React from 'react';

import Header from "../Header"
import ContentNavi from "../ContentNavi"
import NewsPushBody from "./NewsPushBody"

import * as ApiMsgAction  from '../../actions/ApiMsgAction';
import { connect }  from 'react-redux';

class NewsPushPanel extends React.Component {

  componentDidUpdate() {
    if (this.props.apiMsg && this.props.apiMsg.length > 0) {
      alert(this.props.apiMsg)
      this.props.dispatch(
        ApiMsgAction.clearApiMsgAction()
      )
    }
  }

  render() {
      return (
        <div className="main-panel" >
          <div className="content" >
            <ContentNavi title="微信图文推送" />
            <NewsPushBody
              wechat = {this.props.wechat}/>
          </div> //Content is absolute positioned we need to put header below it to overlap it
        </div>
      );
  }
}


const mapStateToProps = (state, ownProps) => {
  // console.log(state)
  return {
          apiMsg: state.apiMsg
         }
}

export default connect(mapStateToProps)(NewsPushPanel);
